package com.qian.apiserver.service;

import com.qian.apiserver.service.IOrderService;
import java.math.BigDecimal;
import com.qian.apiserver.model.Order;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.service.common.BaseRepository;
import java.lang.Byte;
import com.yaowk.service.common.BaseServiceImpl;
import java.lang.Integer;
import com.qian.apiserver.entity.GmOrder;
import com.qian.apiserver.dao.OrderDao;

public abstract class OrderServiceBase extends BaseServiceImpl<Order, GmOrder, Integer> implements IOrderService {

	@Autowired
	private OrderDao dao;

	@Override protected OrderDao getDao() {
	return dao;
	}

	@Override
	protected Order entity2model(GmOrder entity) {
		Order model = null;
		if(isNotEmpty(entity)){
			model = new Order();
			model.setId(entity.getId());
			model.setMoney(entity.getMoney());
			model.setType(entity.getType());
			model.setNumber(entity.getNumber());
			model.setTime(entity.getTime());
			model.setWay(entity.getWay());
			model.setStatus(entity.getStatus());
			model.setGemstone(entity.getGemstone());
			model.setUserId(entity.getUserId());
		}
		return model;
	}

	@Override
	protected GmOrder model2Entity(Order model) {
		GmOrder entity = null;
		if(isNotEmpty(model)){
			entity = new GmOrder();
			entity.setId(model.getId());
			entity.setMoney(model.getMoney());
			entity.setType(model.getType());
			entity.setNumber(model.getNumber());
			entity.setTime(model.getTime());
			entity.setWay(model.getWay());
			entity.setStatus(model.getStatus());
			entity.setGemstone(model.getGemstone());
			entity.setUserId(model.getUserId());
		}
		return entity;
	}

	@Override
	protected GmOrder updateParams(Order model) {
		GmOrder entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getMoney()))
			entity.setMoney(model.getMoney());
		if(isNotEmpty(model.getType()))
			entity.setType(model.getType());
		if(isNotEmpty(model.getNumber()))
			entity.setNumber(model.getNumber());
		if(isNotEmpty(model.getTime()))
			entity.setTime(model.getTime());
		if(isNotEmpty(model.getWay()))
			entity.setWay(model.getWay());
		if(isNotEmpty(model.getStatus()))
			entity.setStatus(model.getStatus());
		if(isNotEmpty(model.getGemstone()))
			entity.setGemstone(model.getGemstone());
		if(isNotEmpty(model.getUserId()))
			entity.setUserId(model.getUserId());
		return entity;
	}


}